package DFS;
import java.util.*;
/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-03-23
 * Time:13:20
 * Text：77. 组合
 */
public class Text11 {
    List<List<Integer>> t1;
    List<Integer> list;
    int num,size;
    public void dfs(int index){
        if(list.size()==size){
            List<Integer> list2=new LinkedList<>(list);
            t1.add(list2);
            return;
        }
        for(int i=index;i<num;i++){
            list.add(i);
            dfs(i+1);
            list.remove(list.size()-1);
        }
    }
    public List<List<Integer>> combine(int n, int k) {
        num=n+1;
        size=k;
        t1=new LinkedList<>();
        list=new LinkedList<>();
        dfs(1);
        return t1;
    }

    public static void main(String[] args) {
        Text11 t1=new Text11();
        t1.combine(4,1);
    }
}
